package cn.xiongxf.feignclient;

import cn.xiongxf.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        // 打印接口错误，方便查找错误
        throwable.printStackTrace();
        return new UserFeignClient() {
            @Override
            public User getById(Long id){
                return new User(-1L,"服务熔断触发","User服务不可用！");
            }
        };
    }
}
